package com.str.set;

/**
 * 
 */
public class Eratosthenes {

	public static IntSet primesLessThan(int m) {

		IntSet sieve = new IntSet(m);
		for (int i = 2; i < m; i++)
			sieve.add(i);

		for (int i = 2; i * i < m; i++)
			if (sieve.contains(i))
				for (int mult = 2 * i; mult < m; mult += i)
					sieve.remove(mult);
		return sieve;
	}

	public static void main(String[] args) {
		int m = 100;
		IntSet sieve = primesLessThan(m);
		System.out.println("Primes less than " + m + " are " + sieve);
	}
}
